﻿namespace Angle.Application.UserServices
{
    using System;
    using System.ComponentModel.DataAnnotations;

    using Skymate;
    using Skymate.Authorization.Attributes;
    using Skymate.Services;
    using Skymate.Services.Dtos;

    /// <summary>
    /// The user service.
    /// </summary>
    [SystemModel(ModelCode = "Adminitrator", ModelName = "系统管理员")]
    public class UserServiceBase : SkymateServiceBase,IUserServiceBase
    {
        [Function(FunctionCode = "Add", FunctionName = "加法计算")]
        [AbpAuthorize("Adminitrator.Add")]
        [NeedLogined()]
        public double Add(double num1, double num2)
        {
            return num1 + num2;
        }

        public void CustomerException()
        {
            throw new Exception("自定义异常信息");
        }

        public SubOutputDto Sub(SubInputDto inputDto)
        {
            return new SubOutputDto()
                       {
                           Result = inputDto.Num1-inputDto.Num2
                       };
        }



    }

    public class SubOutputDto : IOutputDto
    {
        public double Result { get; set; }
    }

    public class SubInputDto : IInputDto
    {
        
        public double Num1 { get; set; }

        public double Num2 { get; set; }

        [Required(ErrorMessage = "必须需要Num3")]
        public string Num3 { get; set; }

    }
}